﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace theguineasyndrome.editor.forms
{
    abstract public class LevelElementNode : TreeNode
    {
        protected Texture2D texture;

        abstract public LevelElement getNewElement(Level level, Vector2 position);

        public LevelElementNode()
        {

        }

        public Texture2D getTexture()
        {
            return texture;
        }

        public void Initialize(EditorForm editor, string image)
        {
            texture = editor.Content.Load<Texture2D>(image);
            texture.Name = image;

            ImageList.ImageCollection images = editor.ImageList.Images;
            images.Add(image, Utils.ImageConverter.fromTexture2D(texture));

            string[] names = image.Split('/');
            Text = names[names.Length - 1];
            ImageIndex = images.IndexOfKey(image);
            SelectedImageIndex = ImageIndex;
        }

    }
}
